# -*- coding: utf-8 -*-
# standard
import os
import sys

# third

# local
_P_PATH =  os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
if _P_PATH not in sys.path:
    sys.path.append(_P_PATH)
from functions.influx_func import *
from functions.collect_func import *
from functions.iot_func import *


"""
@Title:   
@File: __init__.py
@Author: walle 2024年09日28日 19时50分14秒
@Version: 1.0.0
@Desc: 
"""


if __name__ == '__main__':
    db_session = new_db_session()
    now = datetime.now()
    s = update(InFluxDBAlertOrm).where(InFluxDBAlertOrm.id.in_([30])).values(recovery_time=now, status=0)
    db_session.execute(s)
    db_session.commit()
    db_session.close()
    ####################
    kw = {'_check_id': '0dd77933bbf00000', 'type':'超过阈值', '_check_name': '某某餐饮集团温度传感器阈值检查', '_level': 'crit', '_measurement': 'notifications', '_message': 'Check: 某某餐饮集团温度传感器阈值检查 level: crit uuid: 30FFD2053054483209770343 id: 4', '_notification_endpoint_id': '0de0a36c8707a000', '_notification_endpoint_name': 'threshold_endpoint', '_notification_rule_id': '0de0a3913a2f3000', '_notification_rule_name': '超阈值通知规则', '_source_measurement': 'temperature', '_source_timestamp': 1730264940000000000, '_start': '2024-10-30T05:08:00Z', '_status_timestamp': 1730264940000000000, '_stop': '2024-10-30T05:12:00Z', '_time': '2024-10-30T05:12:00Z', '_type': 'threshold', '_version': 1, 'alert_type': 'threshold', 'customer_id': '77', 'grp': '1', 'id': '4', 'store_id': '101', 't': 22.5, 'uuid': '30FFD2053054483209770343'}
    TemperatureSensorEventOrm.add_one(**kw)
    pass